<template>
	<div class="box">
		<div class="box-header">
			<span @click="emits('onLeftClick')">{{ current !== 0 ? '上一题' : '' }}</span>
			<span>宝宝测评</span>
			<span></span>
		</div>
		<div class="box-bottom">
			<div class="progress">
				<div class="progress-box" :style="{ width: width }">
					<span>{{ title }}</span>
				</div>
			</div>
			<div>该项共{{ count }}题目</div>
		</div>
	</div>
</template>

<script lang="ts" setup>
import { computed } from '@vue/reactivity';
import { defineProps, defineEmits } from 'vue'
const props = defineProps(['count', 'title', 'current'])
const emits = defineEmits(['onLeftClick'])
const width = computed(() => props.current / props.count * 100 + '%')


</script>

<style lang="scss" scoped>
.box {
	.box-header {
		display: flex;
		justify-content: space-between;
		padding: 10px;
		align-items: center;
	}

	.box-bottom {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 50px;

		.progress {
			background-color: #ccc;
			height: 6px;
			flex: 1;
			margin: 0 40px;
			border-radius: 6px;

			.progress-box {
				background-color: tomato;
				height: 100%;
				width: 0;
				border-radius: 6px;
				position: relative;

				span {
					position: absolute;
					right: 0;
					top: -40px;
					background-color: tomato;
					font-size: 12px;
					padding: 4px 6px;
					border-radius: 6px;
					transform: translateX(50%);
					white-space: nowrap;
				}
			}
		}
	}
}
</style>